package com.hw.common.enums;

/**
 * @author lipeng
 * @description 语言枚举
 * @date 2023/3/13 19:56
 */
public enum  LanguageEnum {
    LANG_CN(1, "zh_CN"),
    LANG_TW(2, "zh_TW"),
    LANG_EN(3, "en_US"),
    LANG_JP(4, "ja_JP");

    private Integer code;
    private String name;

    LanguageEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 根据code返回枚举对象
     *
     * @param code
     * @return
     */
    public static LanguageEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (LanguageEnum commandEnum : LanguageEnum.values()) {
            if (commandEnum.getCode().intValue() == code.intValue()) {
                return commandEnum;
            }
        }
        return null;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
